var maximumUnits = function (boxTypes, truckSize) {
    let result = 0
    boxTypes.sort((a, b) => {
        return b[1] - a[1]
    })
    for (let i = 0; i < boxTypes.length; i++) {
        if (truckSize < boxTypes[i][0]) {
            result += truckSize * boxTypes[i][1]
            break
        }
        truckSize -= boxTypes[i][0]
        result += boxTypes[i][0] * boxTypes[i][1]
    }
    return result
}
